﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;

namespace MotelServices
{
    public class QuanBUS
    {
        public static string _connString = string.Empty;

        #region Static Contructor
        static QuanBUS()
        {
            _connString = ConfigurationManager.ConnectionStrings["MotelConnectionString"].ConnectionString.ToString();
        } 
        #endregion

        #region Function to get all district
        public static List<QuanDTO> getDistrict()
        {
            List<QuanDTO> ldc = new List<QuanDTO>();
            DataMotelDataContext dtdc = new DataMotelDataContext(_connString);
            try
            {
                var QuanObj = (from dc in dtdc.Quans                                 
                                 select dc);
                foreach (var item in QuanObj)
                {
                    QuanDTO dc = new QuanDTO();
                    dc.MaQuan = item.MaQuan;
                    dc.TenQuan = item.TenQuan;
                    ldc.Add(dc);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                dtdc.Dispose();
            }
            return ldc;
        } 
        #endregion
    }
}